import Vue from 'vue'
import App from './App.vue'
import { Button, Radio, Container, Aside, Header, Main, Menu, Submenu, MenuItemGroup, MenuItem, Dropdown,
         DropdownMenu, DropdownItem, Row, Col, Card, Table, TableColumn, Breadcrumb, BreadcrumbItem,Tag,
         Form,FormItem,Input,Select,Switch,DatePicker,Option,Dialog,Pagination,MessageBox,Message} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import router from '../router/index'
import store from '../src/store/index'
import http from 'axios'
import '../api/mock.js'
import Cookie from 'js-cookie'
Vue.config.productionTip = false
Vue.use(Button);
Vue.use(Radio)
Vue.use(Container)
Vue.use(Aside)
Vue.use(Header)
Vue.use(Main)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItemGroup)
Vue.use(MenuItem)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Row)
Vue.use(Col)
Vue.use(Card)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Tag)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Select)
Vue.use(Switch)
Vue.use(DatePicker)
Vue.use(Option)
Vue.use(Dialog)
Vue.use(Pagination)
Vue.prototype.$http = http
Vue.prototype.$confirm = MessageBox.confirm
Vue.prototype.$message = Message
router.beforeEach((to,from,next)=>{
      store.commit('getToken')
      const token = store.state.user.token
      if(!token && to.name !== 'login'){
        next({name:'login'})
      }else{
        next()
      }
})
new Vue({
  render: h => h(App),
  store,
  router,
  created() {
    store.commit('addMenu', router)
  },
}).$mount('#app')
